package com.wnhz.mayabunny.adapter;

import com.wnhz.mayabunny.R;
import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

@SuppressLint("ViewHolder")
public class Gridview_adapter extends BaseAdapter {
	Context context;
	int[] work_image;
	String[] work_string;

	public Gridview_adapter(Context convertView, int[] work_image, String[] work_string) {
		this.work_image = work_image;
		this.work_string = work_string;
		this.context = convertView;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return work_image.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return work_image[position];
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		convertView = LayoutInflater.from(context).inflate(R.layout.grid_item, null);
		ImageView inImageView = (ImageView) convertView.findViewById(R.id.iv_item);
		TextView textView = (TextView) convertView.findViewById(R.id.tv_item);
		inImageView.setImageResource(work_image[position]);
		textView.setText(work_string[position]);
		// TODO Auto-generated method stub
		return convertView;
	}

}
